-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature addition: Multi-Factor Authentication #401
base: develop
Are you sure you want to change the base?
Conversation
This is super cool, thanks for doing this. Is it also possible to configure the I'll also review the additional routes for the OTP. |
@perfectra1n the environment variables can be set with environment variables (ie export TOTP_ENABLED="true"), -e with docker, and in a .env file in the root directory. Honestly I forgot to update documentation. Whoops! edit: I'm working on adding some pages now. |
Docs complete here. |
@JYC333 I was able to reproduce this and fix it.
I'll have to look into that. I'm not familiar with the client version. @perfectra1n When I build docker it is successful, however the setup page doesn't render any text when I tried it again. Both |
@perfectra1n it looks like the
|
Hmm, I wonder why it's throwing an error then, @eliandoran do you have any idea why by chance? |
@perfectra1n I can confirm that |
@JYC333 I can't replicate your issue. When I build the docker image it runs, but when I navigate to |
Sorry I didn't follow here, is the issue here you for the database issue? And I didn't try to start with docker, I always run with |
There are still some bugs related to internationalization of the server that I'm trying to fix. If it occurs on 'develop' as well it can be ignored for this particular PR. |
@chesspro13 is this still good for testing? :) I wonder what commits I would have to cherry pick to get the Docker container to build, or how would be best to test it...what have you been doing thus far to test it on your branch? |
@perfectra1n I tried it in my dev environment as well as on a fresh VM today. The only issue I have is the one with i18next and text not showing up in the setup screen. What OS are you using? @JYC333 I got the conversations mixed up. That last message I tagged you in was probably supposed to tag @perfectra1n. Been busy with work related projects and school. |
src/services/open_id.ts
Outdated
auth0Logout: false, | ||
baseURL: process.env.BASE_URL, | ||
clientID: process.env.CLIENT_ID, | ||
issuerBaseURL: "https://accounts.google.com/.well-known/openid-configuration", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make issuerBaseUrl
load process.env.OPENID_CONFIG_URL', and now you have support for more services for OpenID Connect. would also prefix all of the Openid Connect related variables with something like
OIDC_' or similar to prevent conflicts.
@@ -69,6 +69,7 @@ | |||
"dayjs": "^1.11.13", | |||
"dayjs-plugin-utc": "0.1.2", | |||
"debounce": "^2.1.0", | |||
"dotenv": "^16.4.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chesspro13 Do we need dotenv now? we can use the inbuilt functionality of nodejs now https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs
Hi, @chesspro13 . What's the status of this PR, do you have the time to work on it? |
quick comment on the env naming: I personally feel like the env vars should be prefixed with some sort of code, to make sure they are clearly belonging to TriliumNext - which will reduce the chance of accidentally resetting/overwriting these. E.g. instead of What do you think? |
quick other remark: since this project seems to use ini files for setting some config options, I would think it makes sense to continue using the existing solution here as well, instead of going to the .env file way. (Admittedly: yes, it also uses optional env variables, but these are e.g. used to "point" to the data-dir (via TRILIUM_DATA_DIR), where the ini file lies (or gets created, if not existing)) https://github.com/TriliumNext/Notes/blob/develop/config-sample.ini what do you think? |
@eliandoran I think I'm fairly close to closing up my personal project that pulled me away from working on Trilium, so I should be back here sometime this month. @pano9000 I'll look into implementing it that way. I didn't particularly like using .env, so that seems like a good solution. |
Features added
Documentation
Testing Instructions
TOTP
OpenID
Currently only compatible with Google. Other services like Authentik and Auth0 are planned on being added.
In order to setup OpenID, you will need to setup a authentication provider. This requires a bit of extra setup. Follow these instructions to setup an OpenID service through google.
Set an environment variable "SSO_ENABLED" to true and add the client ID and secret you obtained from google. Environment variables can be set with a .env file in the root directory, by defining them in the command line, or with a docker container.
.env File
Environment variable (linux)
Docker
After you restart Trilium Notes, you will be redirected to Google's account selection page. Login to an account and Trilium Next will bind to that account, allowing you to login with it.
You can now login using your google account.